﻿package lobby
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.display.Sprite;
	import lobby.events.LobbyEvent;
	import lobby.exchangeddata.HashTable;
	
	/**
	 * ...
	 * @author Nguyen Hoang Giang (Tom)
	 */
	public class HistoryPanelDragonTiger extends HistoryPanelBase
	{
		private static const DRAGON:String = "10";
		private static const TIGER:String = "20";
		private static const TIE:String = "30";
		private static const MAX_NUM_CHECKERS:int = 66;
		
		public override function initBoard(resultArr:Array):void
		{
			removeHistory();
			if (resultArr.length == 0)
				return;
			
			var i:int;
			if (resultArr.length > MAX_NUM_CHECKERS)
			{
				i = Math.abs(resultArr.length - MAX_NUM_CHECKERS - rowNum - 1);
			}
			for (i; i < resultArr.length; i++)
			{
				var iconHis:MovieClip = attachIcon(resultArr[i]);
				iconHis.name = (i + 1).toString();
				if (rowInd + 1 == rowNum)
				{
					rowInd = 0;
					colInd++;
				}
				else
					rowInd++;
			}
		}
		
		public override function attachIcon(type:String):MovieClip
		{
			var hisIcon:MovieClip = MovieClip(new HistoryIconDt());
			var icon:MovieClip = hisIcon.mc;
			hisBoard.addChild(hisIcon);
			hisIcon.x = colInd * 18.5 + 9.25;
			hisIcon.y = rowInd * 18.5 + 9.25;
			//hisIcon.scaleX = hisIcon.scaleY = 0.69;
			
			// dragon 
			if (type == HistoryPanelDragonTiger.DRAGON)
			{
				icon.gotoAndStop("dragon");
				if (GlobalVariables.lang == "G" || GlobalVariables.lang == "B")
				{
					icon.dragon_mc.gotoAndStop("G");
				}
				else
				{
					icon.dragon_mc.gotoAndStop("E");
				}
				icon.dragon_mc.visible = true;
				return hisIcon;
			}
			
			// tiger 
			if (type == HistoryPanelDragonTiger.TIGER)
			{
				icon.gotoAndStop("tiger");
				if (GlobalVariables.lang == "G" || GlobalVariables.lang == "B")
				{
					icon.tiger_mc.gotoAndStop("G");
				}
				else
				{
					icon.tiger_mc.gotoAndStop("E");
				}
				icon.tiger_mc.visible = true;
				return hisIcon;
			}
			
			// tie
			if (type == HistoryPanelDragonTiger.TIE)
			{
				icon.gotoAndStop("tie");
				if (GlobalVariables.lang == "G" || GlobalVariables.lang == "B")
				{
					icon.tie_mc.gotoAndStop("G");
				}
				else
				{
					icon.tie_mc.gotoAndStop("E");
				}
				icon.tie_mc.visible = true;
				return hisIcon;
			}
			return null;
		}
		
	}

}